package com.yjck.fm.spend.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.json.annotations.JSON;

import com.yjck.fm.common.BasicAction;
import com.yjck.fm.common.Constants;
import com.yjck.fm.common.QueryResult;
import com.yjck.fm.spend.bean.SpendType;
import com.yjck.fm.spend.service.SpendManagerService;

public class SpendManagerAction extends BasicAction {

	private static final long serialVersionUID = 1L;
	/**
	 * 返回json数据用
	 */
	private String price;
	private String sdate;
	private String sdesc;
	private String sid;
	private SpendManagerService spendManagerService;
	private String type;
	/**
	 * 获得消费类型列表
	 * @return
	 * @throws Exception
	 */
	public String getSpendTypeList() throws Exception {
		List<SpendType> list = spendManagerService.getSpendTypeList();
		map.put("spendtype", list);
		return SUCCESS;
	}
	/**
	 * 增加消费信息
	 * @return
	 * @throws Exception
	 */
	public String addSpendInfo() throws Exception{
		boolean result = spendManagerService.addSpendInfo(sdesc,sdate,price,type,this.getLoginId());
		if(result){
			map.put("result", Constants.TRUE);		
		}else{
			map.put("result", Constants.FALSE);
		}
		return SUCCESS;
	}
	public String getSpendInfos() throws Exception{
		QueryResult queryResult = this.spendManagerService.getSpendInfos(sdesc,type,sdate,this.getStart(),this.getLimit());
		this.map.put("result", queryResult.getResult());
		this.map.put("count", queryResult.getCount());
		return SUCCESS;
	}
	
	

	public String getPrice() {
		return price;
	}

	public String getSdate() {
		return sdate;
	}

	public String getSdesc() {
		return sdesc;
	}

	public String getSid() {
		return sid;
	}


	public String getType() {
		return type;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public void setSdate(String sdate) {
		this.sdate = sdate;
	}

	public void setSdesc(String sdesc) {
		this.sdesc = sdesc;
	}

	public void setSid(String sid) {
		this.sid = sid;
	}


	public void setType(String type) {
		this.type = type;
	}

	/**
	 * 注入
	 * 
	 * @param spendManagerService
	 */
	public void setSpendManagerService(SpendManagerService spendManagerService) {
		this.spendManagerService = spendManagerService;
	}
}
